package com.itheima.api.treeset.demo04;

public class Student implements Comparable<Student> {

    private String name;
    private int chineseScore;
    private int mathScore;
    private int englishScore;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChineseScore() {
        return chineseScore;
    }

    public void setChineseScore(int chineseScore) {
        this.chineseScore = chineseScore;
    }

    public int getMathScore() {
        return mathScore;
    }

    public void setMathScore(int mathScore) {
        this.mathScore = mathScore;
    }

    public int getEnglishScore() {
        return englishScore;
    }

    public void setEnglishScore(int englishScore) {
        this.englishScore = englishScore;
    }

    public int getTotalScore(){
        return this.chineseScore + this.mathScore + this.englishScore;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", getTotalScore=" + getTotalScore() +
                ", chineseScore=" + chineseScore +
                ", mathScore=" + mathScore +
                ", englishScore=" + englishScore +
                '}';
    }

//    @Override
      //从小到大排序
//    public int compareTo(Student o) {
//        int i = this.getTotalScore() - o.getTotalScore();
//        int i1 = i == 0 ? this.chineseScore - o.chineseScore : i;
//        int i2 = i1 == 0 ? this.mathScore - o.mathScore : i1;
//        int i3 = i2 == 0 ? this.name.compareTo(o.name) : i2;
//        return i3;
//    }

    @Override
    //从大到小排序
    public int compareTo(Student o) {
        int i = o.getTotalScore() - this.getTotalScore();
        int i1 = i == 0 ? o.chineseScore - this.chineseScore : i;
        int i2 = i1 == 0 ? o.mathScore - this.mathScore : i1;
        int i3 = i2 == 0 ? o.name.compareTo(this.name) : i2;
        return i3;
    }
}
